@extends('default.layouts.adminPublic')
@section('title', '权限列表')

@section('content')
        <!--导航开始-->
<div class="crumb_warp">
    <i class="fa fa-home"></i> <a href="{{url('admin')}}">首页</a> &raquo; 权限管理
</div>
<!--导航结束-->

<!--搜索结果页面 列表 开始-->
<form action="#" method="post">
    <div class="result_wrap">
        <div class="result_title">
            <h3>权限列表</h3>
        </div>
        @include('flash::message')
                <!--快捷导航 开始-->
        <div class="result_content">
            <div class="short_wrap">
                <a href="{{url('admin/permission/create')}}"><i class="fa fa-plus"></i>添加权限</a>
                <a href="{{url('admin/permission')}}"><i class="fa fa-recycle"></i>权限列表</a>
            </div>
        </div>
        <!--快捷导航 结束-->
    </div>

    <div class="result_wrap">
        <div class="result_content">
            <table class="list_tab">
                <tr>
                    <th class="tc">排序</th>
                    <th>权限标识</th>
                    <th>权限名称</th>
                    <th>权限说明</th>
                    <th>操作</th>
                </tr>
                @foreach($permissions as $v)
                    <tr>
                        <td class="tc"><input type="text" style="width: 20px;"  onchange="changeOrder(this,'{{$v['id']}}')" value="{{$v['sort']}}"></td>
                        <td>{{$v['name']}}</td>
                        <td>
                            <span style="float: left">{{$v['html']}}{{$v['display_name']}}</span>
                            @if($v['fid'] == '0')
                                <span style="float: left; margin-left:10px;">
                                    <a href="{{url('admin/permission/create/'.$v['id'])}}">[添加方法]</a></span>
                            @endif
                        </td>
                        <td>{{$v['description']}}</td>
                        <td>
                            <a href="{{url('admin/permission/'.$v['id'].'/edit')}}">修改</a>
                            <a onclick="delPre({{$v['id']}})">删除</a>
                        </td>
                    </tr>
                @endforeach
            </table>
            <div class="page_list" style="width: 100%">
                {!! $permissionPage->links() !!}
            </div>
        </div>
    </div>
</form>
<!--搜索结果页面 列表结束-->

<script>

    //权限排序
    function changeOrder(obj,permissionid){
        var sort = $(obj).val();
        $.post("{{url('admin/permission/change_order')}}",{'_token':'{{csrf_token()}}','id':permissionid,'sort':sort},function(data){
            if(data.status == 0){
                layer.msg(data.msg, {icon: 6});
            }else{
                layer.msg(data.msg, {icon: 5});
            }
        });
    }

    //删除权限
    function delPre(permission_id) {
        layer.confirm('您确定要删除这个权限吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("{{url('admin/permission/')}}/"+permission_id,{'_method':'delete','_token':"{{csrf_token()}}"},function (data) {
                if(data.status==0){
                    location.href = location.href;
                    layer.msg(data.msg, {icon: 6});
                }else{
                    layer.msg(data.msg, {icon: 5});
                }
            });
            //            layer.msg('的确很重要', {icon: 1});
        }, function(){

        });
    }

</script>
@endsection